<?php
class CountriesController extends AppController {

	var $name = 'Countries';

    function admin_index () {
        $this->set('countriesList', $this->paginate());
    } // admin_index

    function admin_add () {
        if ($this->data) {
            if ($this->Country->save($this->data)) {
                $this->Session->setFlash('<h4>'.__('New country has been saved',true).'</h4>', 'default', array('class'=>'boxSuccess'));
                $this->redirect('/admin/countries/add');
            }
        }

        $this->pageTitle = __('New Country', true);
    } // admin_add

    function admin_edit ($id=null) {
        if (empty($this->data)) {
            if (!$id) {
                $this->flash('<h4>'.__('Missing required id',true).'</h4>', 'index', 5);
            } else {
                $this->data = $this->Country->findById($id);
            }
        } else {
            if ($this->Country->save($this->data)) {
                $this->Session->setFlash('<h4>'.__('The Country has been saved.',true).'</h4>', 'default', array('class'=>'boxSuccess'));
            }
        }
    } // admin_edit

    function admin_delete ($id=null) {
        if (!$id) {
            $this->flash('<h4>'.__('Missing required id',true).'</h4>', 'index', 5);
        }

        $this->Country->del($id);
        $this->Session->setFlash('<h4>'.__('Country has been deleted',true).'</h4>', 'default', array('class'=>'boxSuccess'));
        $this->redirect('/admin/countries');
    } // admin_delete

    function admin_view ($id=null) {
        if (!$id) {
            $this->Session->setFlash('<h4>'.__('Missing required id',true).'</h4>', 'default', array('class'=>'boxError'));
        }
        $this->set('country', $this->Country->findById($id));
    } // admin_view

} // CountriesController
?>